import requests
page_url="https://www.pearvideo.com/video_1793833"
video_url="https://www.pearvideo.com/videoStatus.jsp?contId=1793833&mrd=0.011477926028411689"
# 在标签中的视频地址
# https://video.pearvideo.com/mp4/short/20240426/cont-1793833-16026694-hd.mp4
# 链接中返回来的视频地址
# https://video.pearvideo.com/mp4/short/20240426/1714982282036-16026694-hd.mp4
headers={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
#     防盗链（溯源，查找访问的上一级）
    "Referer":page_url

}
resp=requests.get(video_url,headers=headers)
video_msg=resp.json()
contId=page_url.split("_")[1]
old_video_url=video_msg["videoInfo"]["videos"]["srcUrl"]
new_video_url=old_video_url.replace(video_msg["systemTime"],"cont-{}".format(contId))
# 将视频保存到本地
videocontent=requests.get(new_video_url).content
f=open("梨视频.mp4","wb").write(videocontent)
print(new_video_url)
